/*
 * tcp_server.h
 *
 *  Created on: 2008-11-27
 *      Author: fanliangliang
 */

#ifndef TCP_SERVER_H_
#define TCP_SERVER_H_

#include "socket_base.h"

BEGIN_NAMESPACE_TOXIC

// forward declaration
class IpAddress;
class SocketAddress;
class TcpSocket;

class TcpServer {
public:
	TcpServer();
	virtual ~TcpServer();

	void close();
	void listen(const IpAddress& address, uint16_t port);
	void listen(const SocketAddress& address);
	void listen(uint16_t port);
	bool isListening() const;
	TcpSocket* accept();

private:
	enum { BACK_LOG = 64 };

private:
	int _descriptor;
	bool _isListening;
};

END_NAMESPACE_TOXIC

#endif /* TCP_SERVER_H_ */
